package Utility;

import java.util.ArrayList;
import java.util.List;

public class ListNode {
	public Integer val;
	public ListNode next;
	public ListNode(Integer x) { val = x; }
	
	public static ListNode MkList(Integer[] lists) {
		List<ListNode> tempList = new ArrayList<ListNode>();
		for(int i=0;i<lists.length;i++) {
			tempList.add(new ListNode(lists[i]));
			if(i>0) {
				tempList.get(i-1).next = tempList.get(i);
			}
		}
		return tempList.get(0);
	}
	@Override
	public String toString() {
		return "ListNode [val=" + val + ", next=" + next + "]";
	}
	
}
